<template>

    <basic-container class="basic-box">
        <el-container>
            <el-aside width="200px">
                <div class="list-tree-box">
                    <avue-tree class="filter-tree" :option="treeOption" v-model="treeForm" :data="treeData"
                               @node-click="nodeClick">
                        <template slot="content">
                            <editor v-if="addDialogTableVisible" @getContent="getAddContent" prop="content"
                                    :cabackcontent="objAdd.content"
                                    :albumCode="albumCode"></editor>
                        </template>
                        <template slot-scope="scope" slot="menuBtn">
                            <div style="padding: 0 10px;">
                                <el-dropdown-item @click.native="addTree">新增</el-dropdown-item>
                                <el-dropdown-item @click.native="editTree(scope.data)">修改</el-dropdown-item>
                                <el-dropdown-item @click.native="delTree(scope.data)">删除</el-dropdown-item>
                            </div>
                        </template>
                    </avue-tree>
                </div>
            </el-aside>
            <el-main>
                <avue-crud :data="data" :option="option" v-model="form" :page="page" @row-del="rowDel"
                           @selection-change="selectionChange"
                           @current-change="currentChange" @size-change="sizeChange" >
                    <template slot-scope slot="menuLeft">

                        <el-button type="primary" size="small" plain class="addBtn" :style="{ display: addClassBtn }"
                                   @click="addPageInfoClass">+新增分类
                        </el-button>

                        <el-button type="primary" size="small" plain class="addBtn" @click="addArticle">+新增</el-button>

                        <el-button type="primary" size="small" plain class="addBtn" @click="allDelete">批量删除</el-button>
                        <el-button type="primary" v-if="showLog" size="small" plain class="addBtn" @click="getSendList">发送记录</el-button>
                    </template>
                    <template slot-scope="{row,type,size}" slot="menu">
                        <el-button :type="type" :size="size" icon="el-icon-view" @click="getDetail(row)">查看</el-button>
                        <el-button :type="type" :size="size" icon="el-icon-edit" @click="getEdit(row)">编辑</el-button>
                        <el-button :style="{display:send}" :type="type" :size="size" icon="el-icon-s-promotion" @click="sendItem(row)">发送
                        </el-button>
                        <el-button :style="{display:send}" :type="type" :size="size" icon="el-icon-s-promotion" @click="getSendItem(row)">发送日志
                        </el-button>
                    </template>
                </avue-crud>
                <el-dialog :title=addOrUpdateClass :visible.sync="treeDialogTableVisible" @close='cancelAddTree'
                           width="70%">
                    <avue-form ref="treeForms" v-model="treeForms" :loading='loading' :option="optionTree"
                               @submit="submitTree">
                        <template slot="menuForm">
                            <el-button size="mini" @click="cancelAddTree">取 消</el-button>
                        </template>
                    </avue-form>
                </el-dialog>
                <el-drawer title="新增分类" :visible.sync="addClassDialogTableVisible" size="70%">
                    <avue-form ref="addArticleClass" v-model="objAddClass" :option="optionViewAddClass">
                        <template slot="menuForm">
                            <el-button type="primary" size="mini" :loading="loadAddClassBtn"
                                       @click="commitAddClassCheck('addArticleClass')">提
                                交
                            </el-button>
                            <el-button size="mini" @click="cancelAddClass()">取 消</el-button>
                        </template>
                    </avue-form>
                </el-drawer>
                <!--在某一分类下新增文章-->
                <el-drawer title="新增" :visible.sync="addDialogTableVisible" @close='cancelAddEdit' size="70%">
                    <avue-form ref="addArticle" v-model="objAdd" :option="optionViewAdd">
                        <template slot="content">
                            <editor v-if="addDialogTableVisible" @getContent="getAddContent" prop="content"
                                    :cabackcontent="objAdd.content"
                                    :albumCode="albumCode"></editor>
                        </template>
                        <template slot="menuForm">
                            <el-button type="primary" size="mini" :loading="loadAddBtn"
                                       @click="commitAddCheck('addArticle')">提 交
                            </el-button>
                            <el-button size="mini" @click="cancelAddEdit">取 消</el-button>
                        </template>
                    </avue-form>
                </el-drawer>

                <el-drawer title="详情" :visible.sync="dialogTableVisible" size="70%">
                    <avue-form v-model="obj" :option="optionView">

                        <template slot="content">
                            <editor prop="content" v-if="dialogTableVisible" :isCheck="isCheck"
                                    :cabackcontent="obj.content"></editor>
                        </template>

                        <template slot="menuForm">
                            <el-button size="mini" @click="cancel()">取 消</el-button>
                        </template>
                    </avue-form>
                </el-drawer>
                <el-drawer title="编辑" :visible.sync="dialogTableVisibleEdit" size="70%">
                    <avue-form ref="editArticle" v-model="objEdit" :option="optionViewEdit">
                        <template slot="content">
                            <editor v-if="dialogTableVisibleEdit" @getContent="getContent" prop="content"
                                    :cabackcontent="objEdit.content"
                                    :albumCode="albumCode"></editor>
                        </template>
                        <template slot="menuForm">
                            <el-button type="primary" size="mini" :loading="loadBtn" @click="commitCheck()">提 交
                            </el-button>
                            <el-button size="mini" @click="cancelEdit()">取 消</el-button>
                        </template>
                    </avue-form>
                </el-drawer>

                <!--发送的弹出框-->
                <el-dialog
                        title="发送"
                        :visible.sync="dialogVisibleSend"
                        width="50%">
                    <avue-form ref="form" v-model="objForm" :option="optionForm" @reset-change="emptytChange"
                               @submit="submitForm">
                        <template slot-scope="scope" slot="bbb">
                            <el-radio-group v-model="objForm.select">
                                <el-radio :label="3">全部店铺</el-radio>
                                <el-radio :label="6">选择店铺</el-radio>
                            </el-radio-group>
                        </template>
                    </avue-form>
                </el-dialog>

            </el-main>
        </el-container>
        <!--		选择店铺  @on-load="chooseTitle=='选择店铺'?listStoreManageFn:mgrListFn"-->
        <el-drawer
                title="选择店铺"
                size="50%"
                :show-close=true
                :visible.sync="sendChooseDrawer"
                :before-close="beforeClose"
                direction="rtl">
            <avue-crud :data="storeList" ref="curdChoose" :option="optionStore" :table-loading='loadingLeader'
                       :page="params" @search-change="chooseSearch" @selection-change="selectionChangeStore"
                       @search-reset="chooseSearchReset" v-model="objStore"
                        @size-change="sizeChangeParams"
                       @current-change="currentChangeParams">
            </avue-crud>
                <div style="display: flex;justify-content: center">
                    <el-button type="primary"  size="mini"  @click="submitChoose">保存</el-button>
                    <el-button  size="mini"  @click="cancleChoose">取消</el-button>
                </div>
        </el-drawer>
        <el-drawer
                title="选择发送对象"
                size="50%"
                :show-close=true
                :visible.sync="sendChooseDrawerLeader"
                direction="rtl" :before-close="beforeClose">
            <avue-crud :data="storeList" ref="curdChooseLeader" :option="optionLeader" :table-loading='loadingLeader'
                       :page="params" @search-change="chooseSearch" @selection-change="selectionChangeLeader"
                       @search-reset="chooseSearchReset" v-model="objStore"
                       @size-change="sizeChangeParams"
                       @current-change="currentChangeParams">
            </avue-crud>
            <div style="display: flex;justify-content: center">
                <el-button type="primary"  size="mini"  @click="submitChoose">保存</el-button>
                <el-button  size="mini"  @click="cancleChoose">取消</el-button>
            </div>
        </el-drawer>
        <el-drawer
                title="发送日志"
                :visible.sync="drawerSendDialog"
                size="60%"
                :before-close="beforeClose"
                direction="rtl">
            <el-menu :default-active="sendIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect">
                <el-menu-item index="1">店铺</el-menu-item>
                <el-menu-item v-if="!isUnit&& !isQuYu" index="0">区域负责人</el-menu-item>
                <el-menu-item v-if="!isAdmin&& !isUnit" index="0">业务单元负责人</el-menu-item>
            </el-menu>
            <avue-crud :data="sendDialogList" ref="curdSend" :option="sendIndex==1?optionSendStore:optionSendLeader" :table-loading='loadingSend'
                       :page="params" @search-change="chooseSearchSend"
                       @search-reset="chooseSearchResetSend" v-model="objSendDialog"
                       @size-change="sizeChangeParamsSend"
                       @current-change="currentChangeParamsSend">
            </avue-crud>
        </el-drawer>
<!--        发送记录-->
        <el-drawer
                title="发送记录"
                :visible.sync="drawerSendAllDialog"
                size="60%"
                :before-close="beforeClose"
                direction="rtl">
            <el-menu :default-active="sendAllIndex" class="el-menu-demo" mode="horizontal" @select="sendHandleSelect">
                <el-menu-item index="1">店铺发送记录</el-menu-item>
                <el-menu-item v-if="!isUnit&& !isQuYu" index="0">区域负责人</el-menu-item>
                <el-menu-item v-if="!isAdmin&& !isUnit" index="0">业务单元负责人</el-menu-item>
<!--                <el-menu-item v-if='!isUnit' index="0">负责人发送记录</el-menu-item>-->
<!--                <el-menu-item index="2">业务单元发送记录</el-menu-item>-->
            </el-menu>
            <avue-crud :data="sendAllDialogList" ref="curdSend" :option="sendAllOption" :table-loading='loadingSendAll'
                       :page="paramsAll" @on-load="getAdminRecordFn"
                       @search-reset="chooseSearchResetSendAll" v-model="objSendAll"
                       @size-change="sizeChangeParamsSendAll"
                       @search-change="chooseSearchAll"
                       @current-change="currentChangeParamsSendAll">
            </avue-crud>
        </el-drawer>
    </basic-container>

</template>

<script>
    import {
        getList,
        remove,
        update,
        add,
        getTree,
        removeAll,
        getDetail,
        listStoreManage,
        mgrList,
        addItem,
        getSelectList,
        getRecord,
        getAdminRecord
    } from "@/api/cms/cmsArticle";

    import {
        addFocus,
        deleteFocus
    } from "@/api/cms/cmsFocus";

    import {
        getListClass,
        removeClass,
        updateClass,
        addClass
    } from "@/api/cms/cmsArticleClass";
    import {
        mapGetters
    } from "vuex";
    import {
        testSort,
        testUrlSourceLength
    } from '@/util/util'
    import {
        bannerTitle,
        bannerDescribe
    } from "@/util/rej"
    import editor from '@/components/editor/richTextEditor';

    var Dict = JSON.parse(localStorage.getItem('mall-dictionary')).content;
    var DIC = {
        VAILD: [{
            label: '全部店铺',
            value: 2
        }, {
            label: '指定店铺',
            value: 1
        }],
        SEX: [{
            label: '店铺',
            value: 1
        }, {
            label: '业务单元',
            value: 2
        }],
        LEADER: [{
            label: '全部业务单元',
            value: 2
        }, {
            label: '指定业务单元',
            value: 1
        }]
    }
    export default {
        props: ["whichType", "whichPassData"],
        data() {
            return {
				showLog:false,
                isAdmin:false,
                isQuYu:false,
                isUnit:false,
                isQuYuAdimi:false,
                sendAllIndex:'1',
                paramsSearchAll:{},
                roleId:'',
                paramsAll:{
                    pageSize: 10,
                    currentPage: 1,
                    total: 0
                },
                sendAllDialogList:[],
                loadingSendAll:true,
                sendDialogList:[],
                objSendAll:{},
                objSendDialog:{},
                loadingSend:true,
                send:"",
                drawerSendDialog:false, // 发送日志的抽屉显隐
                chooseRow: {},
                chooseArr: [],//选择的数组
                chooseTitle: '', // 选择时的弹框标题
                sendChooseDrawer: false,//选择店铺和区域负责任的抽屉显隐
                storeList: [], // 店铺列表
                objForm: {},
                sendChooseDrawerLeader:false,
                dialogVisibleSend: false,
                addOrUpdateClass: '新增分类',
                isCheck: false,
                treeDialogTableVisible: false,
                form: {},
                checkData: {},
                query: {},
                sysFlag: false,
                loading: true,
                loadingLeader:false,
                albumCode: "pic_root",
                addClassBtn: 'none', //隐藏
                rolesTree: [],
                rolesKeys: [],
                idList: [],
                classId: '',
                classIdValue:'',
                box: false,
                obj: {},
                objEdit: {},
                objAdd: {},
                objAddClass: {},
                objEditTemp: {},
                loadBtn: false,
                loadAddBtn: false,
                loadAddClassBtn: false,
                dialogTableVisible: false,
                addDialogTableVisible: false,
                dialogTableVisibleEdit: false,
                addClassDialogTableVisible: false,
                isCmsArticle: false,
                isCmsSysArticle: false,
                isPageInfo: false,
                sysArticlePass: 1,
                page: {
                    pageSize: 10,
                    currentPage: 1,
                    total: 0
                },
                treeForm: {},
                treeForms: {},
                optionTree: {
                    addBtn: false,
                    size: 'mini',
                    border: true,
                    viewBtn: false,
                    editBtn: false,
                    delBtn: false,
                    rowKey: 'id',
                    height: 'auto',
                    menuWidth: 150,
                    align: 'center',
                    submitBtn: true,
                    emptyBtn: false,
                    submitText: '提交',
                    submitSize: 'small',
                    column: [{
                        label: "标题",
                        prop: "title",
                        rules: [{
                            required: true,
                            message: "请输入标题",
                            trigger: "blur"
                        },
                            {
                                validator: bannerTitle,
                                trigger: "blur"
                            }
                        ]
                    }, {
                        label: "分类",
                        prop: "classId",
                        type: 'select',
                        dicData:[],
                        // dicUrl: '/cms/cmsArticleClass/listsDicData',
                        // dicQuery: {
                        //     sysFlag: this.whichPassData,
                        // },
                    }, {
                        label: "描述",
                        prop: "description",
                        type: 'textarea',
                        overHidden: true,
                        span: 24,
                        minRows: 5,
                        rules: [{
                            required: true,
                            message: "请输入内容",
                            trigger: "blur"
                        },
                            {
                                validator: bannerDescribe,
                                trigger: "blur"
                            }
                        ]
                    },
                        {
                            label: "序号",
                            prop: "sequence",
                            rules: [{
                                required: true,
                                message: "请输入序号越小越靠前",
                                trigger: 'blur'
                            },
                                {
                                    validator: testSort,
                                    trigger: "blur"
                                }
                            ]
                        }
                    ]
                },
                option: {
                    addBtn: false,
                    dialogType: 'drawer',
                    type: "drawer",
                    size: 'mini',
                    tip: false,
                    border: true,
                    index: true,
                    viewBtn: false,
                    editBtn: false,
                    delBtn: false,
                    selection: true,
                    rowKey: 'id',
                    height: 'auto',
                    // // calcHeight: 380,
                    menuWidth: 300,
                    labelWidth: 250,
                    align: 'center',
                    column: [{
                        label: "标题",
                        prop: "title",
                        minWidth: 160,
                        align: 'center',
                        rules: [{
                            required: true,
                            message: "请输入标题",
                            trigger: "blur"
                        },
                            {
                                validator: bannerTitle,
                                trigger: "blur"
                            }
                        ]
                    },
                        {
                            label: "关键字",
                            prop: "keyword",
                            minWidth: 160,
                            align: 'center',
                            rules: [{
                                required: true,
                                message: "请输入文章关键字",
                                trigger: "blur"
                            },
                                {
                                    validator: bannerTitle,
                                }
                            ]
                        },
                        {
                            label: "文章作者",
                            prop: "author",
                        },

                        {
                            label: "是否显示",
                            prop: "display",
                            type: 'select',
                            width:50,
                            valueDefault:true,
                            dicData: [{
                                label: "是",
                                value: true
                            },
                                {
                                    label: "否",
                                    value: false
                                }
                            ],
                            rules: [{
                                required: true,
                                message: "请输入是否显示",
                                trigger: "blur"
                            }]
                        },
                        {
                            label: "序号",
                            prop: "sequence",
                            rules: [{
                                required: true,
                                message: "请输入序号越小越靠前",
                                trigger: 'blur'
                            },
                                {
                                    validator: testSort,
                                }
                            ]
                        }
                    ]
                },
                optionView: {
                    submitBtn: false,
                    emptyBtn: false,
                    dialogType: 'drawer',
                    title: '文章管理',
                    type: "drawer",
                    size: 'mini',
                    excelBtn: true,
                    addBtn: true,
                    tip: false,
                    border: true,
                    index: false,
                    selection: true,
                    viewBtn: false,
                    rowKey: 'id',
                    height: 'auto',
                    // // calcHeight: 380,
                    menuWidth: 300,
                    labelWidth: 130,
                    column: [{
                        label: "分类",
                        prop: "classId",
                        fixed: true,
                        type: 'select',
                        dicUrl: '/cms/cmsArticleClass/listsDicData',
                        dicQuery: {
                            sysFlag: this.whichPassData,
                        },
                        disabled: true,
                    },
                        {
                            label: "标记",
                            prop: "mark",
                            fixed: true,
                            disabled: true,
                        },
                        {
                            label: "标题",
                            prop: "title",
                            fixed: true,
                            disabled: true,
                        },
                        {
                            label: "关键字",
                            prop: "keyword",
                            fixed: true,
                            disabled: true,
                        },
                        {
                            label: "内容",
                            formslot: true,
                            span: 24,
                            prop: "content",
                            disabled: true,
                        },
                        {
                            label: "文章作者",
                            prop: "author",
                            fixed: true,
                            disabled: true,
                        },
                        {
                            label: "文章来源",
                            prop: "source",
                            fixed: true,
                            disabled: true,
                        },
                        {
                            label: "链接地址",
                            prop: "url",
                            fixed: true,
                            disabled: true,
                        },
                        {
                            label: "是否显示",
                            prop: "display",
                            fixed: true,
                            type: 'select',
                            valueDefault:true,
                            dicData: [{
                                label: "是",
                                value: true
                            },
                                {
                                    label: "否",
                                    value: false
                                }
                            ],
                            disabled: true,
                        },
                        {
                            label: "序号",
                            prop: "sequence",
                            fixed: true,
                            disabled: true,
                        },
                        {
                            label: "是否系统文章",
                            prop: "sysFlag",
                            fixed: true,
                            type: 'select',
                            dicData: [{
                                label: "是",
                                value: true
                            },
                                {
                                    label: "否",
                                    value: false
                                }
                            ],
                            disabled: true,
                        }
                    ]
                },
                optionViewEdit: {
                    submitBtn: false,
                    emptyBtn: false,
                    dialogType: 'drawer',
                    title: '文章管理',
                    type: "drawer",
                    size: 'mini',
                    excelBtn: true,
                    addBtn: true,
                    tip: false,
                    border: true,
                    index: false,
                    selection: true,
                    viewBtn: false,
                    rowKey: 'id',
                    height: 'auto',
                    // // calcHeight: 380,
                    menuWidth: 300,
                    labelWidth: 130,
                    column: [{
                        label: "分类",
                        prop: "classId",
                        fixed: true,
                        type: 'select',
                        dicUrl: '/cms/cmsArticleClass/listsDicData',
                        dicQuery: {
                            sysFlag: this.whichPassData,
                        },
						rules: [{
						    required: true,
						    message: "请选择分类",
						    trigger: "blur"
						}]
                    },
                        {
                            label: "标记",
                            prop: "mark",
                            fixed: true,
                            disabled: true,
                        },
                        {
                            label: "标题",
                            prop: "title",
                            fixed: true,
                            rules: [{
                                required: true,
                                message: "请输入标题",
                                trigger: "blur"
                            },
                                {
                                    validator: bannerTitle,
                                }
                            ]
                        },
                        {
                            label: "关键字",
                            prop: "keyword",
                            fixed: true,
                            rules: [{
                                required: true,
                                message: "请输入标题",
                                trigger: "blur"
                            },
                                {
                                    validator: bannerTitle,
                                }
                            ]
                        },
                        {
                            label: "内容",
                            formslot: true,
                            span: 24,
                            prop: "content",
                            rules: [{
                                required: true,
                                message: "必须填写文章内容"
                            },],
                        },

                        {
                            label: "文章作者",
                            prop: "author",
                            fixed: true,
                            rules: [{
                                validator: testUrlSourceLength,
                            }]
                        },
                        {
                            label: "文章来源",
                            prop: "source",
                            fixed: true,
                            rules: [{
                                validator: testUrlSourceLength,
                            }]
                        },
                        {
                            label: "链接地址",
                            prop: "url",
                            fixed: true,
                            rules: [{
                                validator: testUrlSourceLength,
                            }]
                        },
                        {
                            label: "是否显示",
                            prop: "display",
                            fixed: true,
                            type: 'select',
                            dicData: [{
                                label: "是",
                                value: true
                            },
                                {
                                    label: "否",
                                    value: false
                                }
                            ],
                            valueDefault:true,
                        },
                        {
                            label: "序号",
                            prop: "sequence",
                            fixed: true,
                            rules: [{
                                required: true,
                                message: "请输入序号越小越靠前",
                                trigger: 'blur'
                            },
                                {
                                    validator: testSort,
                                }
                            ]
                        }
                    ]
                },
                optionViewAdd: {
                    submitBtn: false,
                    emptyBtn: false,
                    dialogType: 'drawer',
                    title: '文章管理',
                    type: "drawer",
                    size: 'mini',
                    excelBtn: true,
                    addBtn: true,
                    tip: false,
                    border: true,
                    index: false,
                    selection: true,
                    viewBtn: false,
                    rowKey: 'id',
                    height: 'auto',
                    // // calcHeight: 380,
                    menuWidth: 300,
                    labelWidth: 130,
                    column: [{
                        label: "分类",
                        prop: "classId",
                        fixed: true,
                        type: 'select',
                        dicUrl: '/cms/cmsArticleClass/listsDicData',
                        dicQuery: {
                            sysFlag: this.whichPassData,
                        },
                        rules: [{
                            required: true,
                            message: "请选择分类",
                            trigger: "change"
                        }]
                    },
                        {
                            label: "标记",
                            prop: "mark",
                            fixed: true,
                            rules: [{
                                required: true,
                                message: "请填写标记",
                                trigger: "blur"
                            },
                                {
                                    validator: bannerTitle,
                                }
                            ]
                        },
                        {
                            label: "标题",
                            prop: "title",
                            fixed: true,
                            rules: [{
                                required: true,
                                message: "请输入标题",
                                trigger: "blur"
                            },
                                {
                                    validator: bannerTitle,
                                }
                            ]
                        },
                        {
                            label: "关键字",
                            prop: "keyword",
                            fixed: true,
                            rules: [{
                                required: true,
                                message: "请输入关键字",
                                trigger: "blur"
                            },
                                {
                                    validator: bannerTitle,
                                }
                            ]
                        },
                        {
                            label: "内容",
                            formslot: true,
                            span: 24,
                            prop: "content",
                            rules: [{
                                required: true,
                                message: "必须填写文章内容"
                            },],
                        },

                        {
                            label: "文章作者",
                            prop: "author",
                            fixed: true,
                            rules: [{
                                validator: testUrlSourceLength,
                            }]
                        },
                        {
                            label: "文章来源",
                            prop: "source",
                            fixed: true,
                            rules: [{
                                validator: testUrlSourceLength,
                            }]
                        },
                        {
                            label: "链接地址",
                            prop: "url",
                            fixed: true,
                            rules: [{
                                validator: testUrlSourceLength,
                            }]
                        },
                        {
                            label: "是否显示",
                            prop: "display",
                            fixed: true,
                            type: 'select',
                            valueDefault:true,
                            dicData: [{
                                label: "是",
                                value: true
                            },
                                {
                                    label: "否",
                                    value: false
                                }
                            ],
                        },
                        {
                            label: "序号",
                            prop: "sequence",
                            fixed: true,
                            rules: [{
                                required: true,
                                message: "请输入序号越小越靠前",
                                trigger: 'blur'
                            },
                                {
                                    validator: testSort,
                                }
                            ]
                        }
                    ]
                },
                optionViewAddClass: {
                    submitBtn: false,
                    emptyBtn: false,
                    dialogType: 'drawer',
                    title: '文章分类新增',
                    type: "drawer",
                    size: 'mini',
                    excelBtn: true,
                    addBtn: true,
                    tip: false,
                    border: true,
                    index: false,
                    selection: true,
                    viewBtn: false,
                    rowKey: 'id',
                    height: 'auto',
                    // // calcHeight: 380,
                    menuWidth: 300,
                    labelWidth: 130,
                    column: [{
                        label: "标题",
                        prop: "title",
                        fixed: true,
                        rules: [{
                            required: true,
                            message: "请输入标题",
                            trigger: "blur"
                        },
                            {
                                validator: bannerTitle,
                            }
                        ]
                    },
                        {
                            label: "描述",
                            prop: "description",
                            type: 'textarea',
                            overHidden: true,
                            span: 24,
                            minRows: 5,
                            rules: [{
                                required: true,
                                message: "请输入内容",
                                trigger: "blur"
                            },
                                {
                                    validator: bannerDescribe,
                                }
                            ]
                        },
                        {
                            label: "序号",
                            prop: "sequence",
                            fixed: true,
                            rules: [{
                                required: true,
                                message: "请输入序号越小越靠前",
                                trigger: 'blur'
                            },
                                {
                                    validator: testSort,
                                }
                            ]
                        }
                    ]
                },
                treeOption: {
                    dialogWidth: "70%",
                    nodeKey: "id",
                    size: "small",
                    addBtn: false,
                    editBtn: false,
                    filter: false,
                    delBtn: false,
                    rowKey: 'id',
                    formOption: {
                        labelWidth: 130,
                        query: {},
                        loading: true,
                        addBtn: true,
                        saveBtn: true,
                        menuPostion: "right",
                        submitBtn: true,
                        emptyBtn: true,
                        submitSize: "small",
                        submitText: "保存",
                        emptyText: "清空",
                        emptySize: "small",
                        column: [{
                            label: "父类",
                            prop: "parentId",
                            fixed: true,
                            search: true,
                            type: 'select',
                            dicUrl: '/cms/cmsArticleClass/listsDicData',
                            dicQuery: {
                                sysFlag: this.whichPassData,
                            },
                        },
                            {
                                label: "描述",
                                prop: "description",
                                type: 'textarea',
                                overHidden: true,
                                span: 24,
                                minRows: 5,
                                rules: [{
                                    required: true,
                                    message: "请输入内容",
                                    trigger: "blur"
                                },
                                    {
                                        validator: bannerDescribe,
                                    }
                                ]
                            },
                            {
                                type: "input",
                                label: "序号",
                                span: 12,
                                display: true,
                                prop: "sequence",
                                required: true,
                                rules: [{
                                    required: true,
                                    message: "请输入序号",
                                },
                                    {
                                        validator: testSort,
                                        trigger: 'blur'
                                    }
                                ],
                            }
                        ]
                    },
                    props: {
                        labelText: "分类名称",
                        value: "value",
                        label: "label",
                        children: "children",
                    }
                },
                optionStore: {
                    menu: false,
                    addBtn: false,
                    searchBtnText: true,
                    saveBtn: false,
                    cancalBtn:false,
                    clearBtn: false,
                    reserveSelection: false,
                    selection: true,
                    page: false,
                    align: 'center',
                    menuAlign: 'center',
                    column: [
                        {
                            label: '店铺名称',
                            prop: 'storeName',
                            search: true,
                            searchSpan:10,
                            searchLabelWidth:100,
                        },
                    ]
                },
                optionLeader: {
                    menu: false,
                    addBtn: false,
                    searchBtnText: true,
                    saveBtn: true,
                    clearBtn: true,
                    reserveSelection: false,
                    selection: true,
                    page: false,
                    align: 'center',
                    menuAlign: 'center',
                    column: [
                        {
                            label: '负责人',
                            prop: 'name',
                            search: true,
                            searchSpan:10,
                            searchLabelWidth:100,
                        },{
                            label: '区域',
                            prop: 'organizationName',
                            // search: true,
                            // searchSpan:10,
                            // searchLabelWidth:100,
                        }, {
                            label: '手机号',
                            prop: 'phone'
                        }
                    ]
                },
                data: [],
                drawerSendAllDialog:false, //发送列表弹出框
                treeData: [],
                params: {
                    pageSize: 10,
                    currentPage: 1,
                    total: 0
                },
                objStore: {},
                optionSendStore:{
                    menu: false,
                    addBtn: false,
                    searchBtnText: true,
                    saveBtn: true,
                    clearBtn: true,
                    reserveSelection: false,
                    selection: false,
                    page: false,
                    align: 'center',
                    menuAlign: 'center',
                    column: [
                        {
                            label: '发送时间',
                            prop: 'addTime',
                            // search: true,
                            searchSpan:10,
                            searchLabelWidth:100,
                        },
                        {
                            label: '店铺名称',
                            prop: 'storeName',
                            // search: true,
                            searchSpan:10,
                            searchLabelWidth:100,
                        }
                    ]
                },
                optionSendLeader:{
                    menu: false,
                    addBtn: false,
                    searchBtnText: true,
                    saveBtn: false,
                    clearBtn: false,
                    reserveSelection: false,
                    selection: false,
                    page: false,
                    align: 'center',
                    menuAlign: 'center',
                    column: [
                        {
                            label: '发送时间',
                            prop: 'addTime',
                            // search: true,
                            searchSpan:10,
                            searchLabelWidth:100,
                        },
                        {
                            label: '接收人',
                            prop: 'storeName',
                            // search: true,
                            searchSpan:10,
                            searchLabelWidth:100,
                        }
                    ]
                },
                sendAllOption:{
                    border:true,
                    menu: false,
                    addBtn: false,
                    searchBtnText: true,
                    saveBtn: false,
                    clearBtn: false,
                    reserveSelection: false,
                    selection: false,
                    page: false,
                    align: 'center',
                    menuAlign: 'center',
                    column: [
                        {
                            label: '发送时间',
                            prop: 'addTime',
                            // search: true,
                            searchSpan:10,
                            searchLabelWidth:100,
                        },
                        {
                            label: '发送人',
                            prop: 'sendUser',
                            // search: true,
                            searchSpan:10,
                            searchLabelWidth:100,
                        },
                        {
                            label: '发送对象',
                            prop: 'storeName',
                            // search: true,
                            searchSpan:10,
                            searchLabelWidth:100,
                        },
                    ]
                },
                sendIndex:'1',
                sendItemId:'',
            };
        },
        components: {
            editor,
        },
        computed: {
            ...mapGetters(["permission", 'userInfo']),
            permissionList() {
                return {};
            },
            optionForm() {
                return {
                    submitBtn: true,
                    mockBtn: true,
                    submitText: '完成',
                    printBtn: true,
                    emptyText: "取消",
                    column: [
                        {
                            label: "发送对象",
                            value: 2,
                            prop: "userType",
                            span: 24,
                            type: "radio",
                            dicData: DIC.SEX,
                            mock: {
                                type: 'dic'
                            },
                            display: true,
                            row: true,
                            // rules:[{
                            //     required:true,
                            //     message:'请选择发送对象'
                            // }],
                            change: ({value}) => {
                                this.storeList=[]
                                this.params = {
                                    pageSize: 10,
                                        currentPage: 1,
                                        total: 0
                                }
                                if (value == 1) {
                                    this.optionForm.column[1].display = true
                                    this.optionForm.column[2].display = false
                                } else if (value == 2) {
                                    this.optionForm.column[1].display = false
                                    this.optionForm.column[2].display = true
                                } else {
                                    console.log('aaaaaa1111111')
                                    this.optionForm.column[1].display = false
                                    this.optionForm.column[2].display = false
                                }

                            }
                        },
                        {
                            label: "选择",
                            prop: "bbb",
                            span: 24,
                            type: "radio",
                            dicData: DIC.VAILD,
                            mock: {
                                type: 'dic'
                            },
                            display: false,
                            row: true,
                            rules:[{
                                required:true,
                                message:'请选择发送对象'
                            }],
                            change: ({value, column}) => {
                                console.log('value', value)
                                if (value == 1) {
                                    this.sendChooseDrawer = true
                                    this.chooseTitle = '选择店铺'
                                    this.listStoreManageFn()
                                }
                            }
                        },
                        {
                            label: "选择",
                            prop: "ccc",
                            span: 24,
                            type: "radio",
                            dicData: DIC.LEADER,
                            mock: {
                                type: 'dic'
                            },
                            display: false,
                            row: true,
                            rules:[{
                                required:true,
                                message:'请选择发送对象'
                            }],
                            change: ({value, column}) => {
                                if (value == 1) {
                                    this.chooseTitle = '选择业务单元'
                                    this.mgrListFn()
                                    this.sendChooseDrawerLeader = true
                                }
                            }
                        },
                    ]
                }
            }
        },
        created() { //roleId
            this.isAdmin = this.userInfo.roleIds.includes(1) || this.userInfo.roleIds.includes(8)
            this.isQuYu = this.userInfo.roleIds.includes(10)
            this.isQuYuAdimin = this.userInfo.roleIds.includes(11)
            this.isUnit = this.userInfo.roleIds.includes(12)
             if(this.isAdmin) {
                 this.roleId=1
                 DIC={
                     VAILD: [{
                         label: '全部店铺',
                         value: 2
                     }, {
                         label: '指定店铺',
                         value: 1
                     }],
                     SEX: [{
                         label: '店铺',
                         value: 1
                     }, {
                         label: '区域负责人',
                         value: 2
                     }],
                     LEADER: [{
                         label: '全部区域负责人',
                         value: 2
                     }, {
                         label: '指定区域负责人',
                         value: 1
                     }]
                 }
             }else if(this.isQuYu) {
                 this.roleId=11
                 DIC={
                     VAILD: [{
                         label: '全部店铺',
                         value: 2
                     }, {
                         label: '指定店铺',
                         value: 1
                     }],
                     SEX: [{
                         label: '店铺',
                         value: 1
                     }, {
                         label: '业务单元',
                         value: 2
                     }],
                     LEADER: [{
                         label: '全部业务单元',
                         value: 2
                     }, {
                         label: '指定业务单元',
                         value: 1
                     }]
                 }
             }else if(this.isQuYuAdimin) {
                 this.roleId=10
                 DIC={
                     VAILD: [{
                         label: '全部店铺',
                         value: 2
                     }, {
                         label: '指定店铺',
                         value: 1
                     }],
                     SEX: [{
                         label: '店铺',
                         value: 1
                     }, {
                         label: '业务单元',
                         value: 2
                     }],
                     LEADER: [{
                         label: '全部业务单元',
                         value: 2
                     }, {
                         label: '指定业务单元',
                         value: 1
                     }]
                 }
             }else if(this.isUnit) {
                 this.roleId=12
                 DIC={
                     VAILD: [{
                         label: '全部店铺',
                         value: 2
                     }, {
                         label: '指定店铺',
                         value: 1
                     }],
                     SEX: [{
                         label: '店铺',
                         value: 1
                     }],
                 }
             }
            console.log('thissss',this.isAdmin,this.isQuYu,this.isUnit)
            if (this.whichType == "cmsArticle") {
                //普通文章管理
                this.isCmsArticle = true;
				this.showLog=true
                this.isCmsSysArticle = false;
                this.isPageInfo = false;
                this.sysFlag = false;
                this.sysArticlePass = 0;
                this.send="";
            } else if (this.whichType == "cmsSysArticle") {
                //系统文章管理
                this.isCmsArticle = false;
				this.showLog=false
                this.isCmsSysArticle = true;
                this.isPageInfo = false;
                this.sysFlag = true;
                this.sysArticlePass = 1;
                this.send="none"
            }
            this.getTreeList();
            this.onLoad(this.page);

        },
        watch: {
            'treeData'() {
                if (this.treeData.length == 0) {
                    //展示
                    this.addClassBtn = '';
                } else {
                    //不显示
                    this.addClassBtn = 'none';
                }

            },
        },
        methods: {
            beforeClose(done) {
                this.objForm.bbb=''
                this.objForm.ccc=''
                this.sendIndex='1'
                this.sendAllIndex='1'
                done()
            },
            handleSelect(key,keyPath) {
                this.sendIndex = key
                this.loadingSend = true
                this.getRecordFn()
                this.params = {
                    pageSize: 10,
                        currentPage: 1,
                        total: 0
                }
                this.sendDialogList=[]
            },
            submitChoose() {
                if(this.chooseArr.length<1) {
                    this.$message({
                        message: '请选择发送对象',
                        type: 'error'
                    });
                    return
                }
                this.sendChooseDrawer=false
                this.sendChooseDrawerLeader = false
            },
            cancleChoose() {
                this.objForm.bbb=''
                this.objForm.ccc=''
                this.sendChooseDrawer=false
                this.sendChooseDrawerLeader = false
            },
            getAdminRecordFn() {
                this.loadingSendAll=false
                let obj={
                    roleId:this.roleId,
                    userType:this.sendAllIndex,
                    page:this.paramsAll.currentPage,
                    size:this.paramsAll.pageSize,
                    ...this.paramsSearchAll
                }
                getAdminRecord(obj).then(res=>{
                    if(res.data.code==200) {
                        this.sendAllDialogList =res.data.data
                        this.paramsAll.total = res.data.count
                        if(res.data.data.length==0&&this.paramsAll.currentPage!=1) {
                            this.paramsAll.currentPage -= 1
                            this.getAdminRecordFn()
                        }
                    }else {
                        this.$message({
                            message: res.data.message,
                            type: 'error'
                        });
                    }
                })
            },
            // 获取发送对象
            getRecordFn() {
                let query={
                    page:this.params.currentPage,
                    size:this.params.pageSize,
                    userType:this.sendIndex,
                    articleId:this.sendItemId,
                }
                getRecord(query).then(res=>{
                    if(res.data.code==200) {
                        this.loadingSend = false
                        this.sendDialogList =(res.data.data)
                        this.params.total = res.data.count
                    }else {
                        this.$message({
                            message: res.data.message,
                            type: 'error'
                        });
                        this.loadingSend = false
                    }
                })
            },
            // 获取店铺
            listStoreManageFn(data) {
                console.log('this.loadingLeader',this.loadingLeader)
                this.loadingLeader = true
               
                let query = {
                    page: this.params.currentPage,
                    size: this.params.pageSize,
                    ...data
                }
                listStoreManage(query).then(res => {
                    if (res.data.code == 200) {
						 this.storeList=[]
                        this.storeList = res.data.data
                        this.params.total = res.data.count
                        this.loadingLeader = false
                    }else{
                        this.$message({
                            message: res.data.message,
                            type: 'error'
                        });
                        this.loadingLeader = false
                    }
                    // console
                })
            },
            // 获取业务单元
            mgrListFn(data) {
                this.loadingLeader = true
                
                let query = {
                    page: this.params.currentPage,
                    size: this.params.pageSize,
                    ...data
                }
                mgrList(query).then(res => {
                    if (res.data.code == 200) {
						this.storeList=[]
                        this.storeList = res.data.data
                        this.params.total = res.data.count
                        this.loadingLeader = false
                    }else {
                        this.$message({
                            message: res.data.message,
                            type: 'error'
                        });
                        this.loadingLeader = false
                    }
                })
            },
            // 发送提交时调用
            addItemFn(data, done) {
                addItem(data).then(res => {
                    if (res.data.code == 200) {
                        // if (done) {
                            done();
                            this.dialogVisibleSend = false
                            this.$refs.form.resetForm()
                            this.$message({
                                message: '发送成功',
                                type: 'success'
                            });
                        // }
                    }else {
                        done();
                        this.dialogVisibleSend = false
                        this.$refs.form.resetForm()
                        this.$message({
                            message: '发送失败',
                            type: 'error'
                        });
                    }
                })
            },
            sizeChangeParams(val) {
                this.params.pageSize = val
                if (this.chooseTitle == '选择店铺') {
                    this.listStoreManageFn()
                } else {
                    this.mgrListFn()
                }
            },
            sizeChangeParamsSend(val) {
                this.params.pageSize = val
                this.getRecordFn()
            },
            sizeChangeParamsSendAll(val) {
                this.paramsAll.pageSize = val
                this.getAdminRecordFn()
            },
            currentChangeParams(val) {
                this.chooseArr=[]
                this.params.currentPage = val
                if (this.chooseTitle == '选择店铺') {
                    this.listStoreManageFn()
                } else {
                    this.mgrListFn()
                }
            },
            // 发送日志的页码切换
            currentChangeParamsSend(val) {
                this.params.currentPage = val
                this.getRecordFn()
            },
            // 发送日志的页码切换
            currentChangeParamsSendAll(val) {
                this.paramsAll.currentPage = val
                this.getAdminRecordFn()
            },
            // 选择时触发 selectionChangeLeader
            selectionChangeStore(row) {
                console.log('row', row)
                let chooseArr = []
                if (row.length > 0) {
                    for (let item of row) {
                        chooseArr.push(item.userId)
                    }
                    this.chooseArr = chooseArr
                } else {
                    this.chooseArr = [];
                }
            },
            selectionChangeLeader(row) {
                let chooseArr = []
                if (row.length > 0) {
                    for (let item of row) {
                        chooseArr.push(item.id)
                    }
                    this.chooseArr = chooseArr
                } else {
                    this.chooseArr = [];
                }
            },
            // 搜索
            chooseSearch(params) {
                this.loadingLeader=true
                this.paramsSearch = params
                this.params.currentPage = 1
                if (this.chooseTitle == '选择店铺') {
                    this.listStoreManageFn(this.paramsSearch)
                } else {
                    this.mgrListFn(this.paramsSearch)
                }
            },
            // 发送日志的搜索
            chooseSearchSend() {
                this.params.currentPage =1
                this.loadingSend=true
                this.getRecordFn()
            },
            chooseSearchAll(params) {
                this.loadingSendAll=true
                this.paramsSearchAll = params
                this.paramsAll.currentPage = 1
                this.getAdminRecordFn()
            },
            //清空搜索
            chooseSearchReset() {
                this.paramsSearch = {}
                this.loadingLeader=true
                if (this.chooseTitle == '选择店铺') {
                    this.listStoreManageFn(this.paramsSearch)
                } else {
                    this.mgrListFn(this.paramsSearch)
                }
            },
            chooseSearchResetSendAll() {
            this.paramsSearchAll={}
                this.loadingSendAll = true
                this.getAdminRecordFn()
            },
            chooseSearchResetSend() {
                this.loadingSend = true
                this.getRecordFn()
            },
            rowSave(row, loading, done) {
                row.position = row.positionIds;
                row.deptName = row.$deptId;
                row.repassword = row.password;
                add(row).then(() => {
                    loading();
                    this.onLoad(this.page);
                    this.$message({
                        type: "success",
                        message: "操作成功!"
                    });
                }, error => {
                    done();
                    console.log(error);
                });
            },
            rowUpdate(row, index, loading, done) {
                row.position = row.positionIds;
                update(row).then(() => {
                    loading();
                    this.onLoad(this.page);
                    this.$message({
                        type: "success",
                        message: "操作成功!"
                    });
                }, error => {
                    done();
                    console.log(error);
                });
            },
            searchReset() {
                this.query = {};
                this.idList = []
                this.beginTime = ''
                this.endTime = ''
                this.onLoad(this.page);
            },
            searchChange(params, done) {
                this.query = params;
                this.onLoad(this.page, params, done);
            },
            currentChange(currentPage) {
                this.page.currentPage = currentPage;
                this.onLoad(this.page);
            },
            sizeChange(pageSize) {
                this.page.pageSize = pageSize;
                this.onLoad(this.page);
            },
            refreshChange() {
                this.onLoad(this.page);
            },
            onLoad(page, params = {
                classId: this.classIdValue
            }, done) {
                this.loading = true;
                params.sysFlag = this.sysFlag;
                getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
                    if (done) {
                        done();
                    }
                    this.loading = false;
                    const data = res.data;
                    this.page.total = data.count;
                    this.data = data.data;
                });
            },
            getTreeList() {
                this.treeData = []
                getTree(this.sysArticlePass).then(res => {
                    for (let item of res.data.data) {
                        item.id = item.value;
                    }
                    this.treeData = res.data.data
                })
            },
            nodeClick(data) {
                console.log(data,'新增分类id打印值')
                this.classId = data.label;
                this.classIdValue=data.value;
                this.page.currentPage = 1;
                this.onLoad(this.page);
            },
            cancelAddTree() {
                this.$refs.treeForms.resetForm()
                this.$refs.treeForms.clearValidate();
                this.treeDialogTableVisible = false;
            },
            addTree() {
                this.treeDialogTableVisible = true;
                this.addOrUpdateClass = "新增分类";
                this.loadClass();
            },
            editTree(row) {
                row.classId = row.nodeParentId;
                this.treeForms = row;
                this.treeDialogTableVisible = true;
                this.addOrUpdateClass = "修改分类";
                this.loadClass();
            },
            delTree(row) {
                this.$confirm("是否确认删除该节点?", {
                    confirmButtonText: "确定",
                    cancelButtonText: "取消",
                    type: "warning"
                }).then(() => {
                    return removeClass(row.value).then(res => {
                        if (res.data.success) {
                            this.loading = false;
                            this.$message.success("操作成功!");
                            this.getTreeList();
                            // location.reload();
                        } else {
                            this.$message.error(res.data.message);
                        }
                    });
                });
            },
            submitTree(loading, done) {
                this.loading = false
                if (this.treeForms.id) {
                    if(!this.treeForms.classId){
                        delete this.treeForms.classId
                    }
                    else {
                        this.treeForms.parentId = this.treeForms.classId;
                    }
                    delete this.treeForms.$classId
                    updateClass(this.treeForms).then(res => {
                        if (res.data.code == 200) {
                            this.$message.success("修改成功!");
                            this.getTreeList();
                            // location.reload();
                        } else {
                            this.$message.error(res.data.message);
                        }
                        done();
                    }, error => {
                        done();
                    });
                } else {
                    if(this.treeForms.classId){
                        this.treeForms.parentId = this.treeForms.classId;
                    }
                    else {
                        delete this.treeForms.classId;
                    }
                    delete this.treeForms.$classId;
                    this.treeForms.sysFlag = this.sysFlag;
                    addClass(this.treeForms).then(res => {
                        if (res.data.code == 200) {
                            this.$message.success("操作成功!");
                            this.getTreeList();
                            // location.reload();
                        } else {
                            this.$message.error(res.data.message);
                        }
                        done();
                    }, error => {
                        done();
                    });
                }
                this.cancelAddTree()

            },
            rowDel(row) {
                this.$confirm("确定将选择数据删除?", {
                    confirmButtonText: "确定",
                    cancelButtonText: "取消",
                    type: "warning"
                }).then(() => {
                    return remove(row.id).then(() => {
                        this.onLoad(this.page);
                        this.$message({
                            type: "success",
                            message: "操作成功!"
                        });
                    });
                });
            },
            //监控多选点击事件
            selectionChange(row) {
                var idList = []
                if (row.length > 0) {
                    for (let item of row) {
                        idList.push(item.id)
                    }
                    console.log(idList)
                    this.idList = idList
                } else {
                    this.idList = [];
                }
            },


            addArticle() {
                this.objAdd.classId = this.classId
                this.addDialogTableVisible = true;
                this.$nextTick(() => {
                    this.$refs["addArticle"].clearValidate();
                });
            },
            // 获取发送记录
            getSendList() {
                this.drawerSendAllDialog = true
                this.getAdminRecordFn()
            },
            // tab切换
            sendHandleSelect(key) {
                this.sendAllIndex = key
                this.getAdminRecordFn()
            },
            allDelete() {
                removeAll(this.idList).then(res => {
                    if (this.idList.length > 0) {
                        if (res.data.success) {
                            this.page.currentPage = 1;
                            this.onLoad(this.page, this.params);
                            this.idList = [];
                            this.$message({
                                type: "success",
                                message: "操作成功!"
                            });
                        } else {
                            this.$message.error(res.data.message);
                        }
                    } else {
                        this.$message({
                            type: "error",
                            message: "至少选择一笔数据"
                        });
                    }

                }, error => {
                    console.log(error);
                });
            },

            //查看
            getDetail(row) {
                getDetail(row.id).then(res => {
                    if (res.data.code == 200) {
                        this.obj = res.data.data;
                        console.log(this.obj);
                        this.dialogTableVisible = true;
                        this.isCheck = true;
                    } else {
                        this.$message({
                            message: res.data.message,
                            type: 'error'
                        });
                        return;
                    }
                });
            },

            //编辑
            getEdit(row) {
                getDetail(row.id).then(res => {
                    if (res.data.code == 200) {
                        this.objEdit = res.data.data;
                        this.objEditTemp = res.data.data;
                        this.dialogTableVisibleEdit = true
                    } else {
                        this.$message({
                            message: res.data.message,
                            type: 'error'
                        });
                        return;
                    }
                });
            },
            // 发送
            sendItem(row) {
                console.log('rowww', row)
                this.chooseRow = row
                this.dialogVisibleSend = true
                this.optionForm.column[1].display = false
                this.optionForm.column[2].display = false
                // this.$refs.form.resetForm()
            },
            // 发送日志
            getSendItem(item) {
                this.drawerSendDialog = true
                this.sendItemId = item.id
                this.loadingSend = true
                this.getRecordFn()
            },
            emptytChange() {
                this.chooseArr = []
                this.$refs.form.resetForm()
                // this.optionForm.column[1].display = false
                // this.optionForm.column[2].display = false
                this.dialogVisibleSend = false

                // this.$refs.curdChoose.selectClear()
            },
            //提交选中的店铺或业务单元
            submitForm(form, done) {
                if(this.objForm.userType !='1' && this.objForm.userType !='2') {
                    console.log('this.objForm.userType',this.objForm.userType)
                    this.$message({
                        message: '请选择发送对象',
                        type: 'error'
                    });
                    done()
                    return
                }
                if(this.objForm.userType==1 && this.objForm.bbb=='') {
                    this.$message({
                        message: '请选择发送对象',
                        type: 'error'
                    });
                    done()
                    return
                }
                if(this.objForm.userType==2 && this.objForm.ccc=='') {
                    this.$message({
                        message: '请选择发送对象',
                        type: 'error'
                    });
                    done()
                    return
                }
                if (this.objForm.userType == 1) {
                    if(this.objForm.bbb==1 && this.chooseArr.length<1) {
                        this.$message({
                            message: '请选择发送对象',
                            type: 'error'
                        });
                        setTimeout(() => {
                            done()
                            this.$refs.form.resetForm()
                            this.optionForm.column[1].display = false
                            this.optionForm.column[2].display = false
                        }, 1000)
                        return
                    }
                    this.addItemFn({
                        userType: 1,
                        articleId: this.chooseRow.id,
                        userId: this.chooseArr.length? this.chooseArr : 0
                    },done)
                } else if (this.objForm.userType == 2){
                    if(this.objForm.ccc==1 && this.chooseArr.length<1) {
                        this.$message({
                            message: '请选择发送对象',
                            type: 'error'
                        });
                        done()
                        return
                    }
                    this.addItemFn({
                        userType: 0,
                        articleId: this.chooseRow.id,
                        userId: this.chooseArr.length? this.chooseArr : 0
                    },done)
                }

            },
            //新增之后提交
            commitAddCheck(addArticle) {
                if (!this.objAdd.content) {
                    this.$message.error('内容不能为空');
                    return;
                }
                setTimeout(() => {
                    this.loadAddBtn = false;
                }, 1000);
                this.$refs['addArticle'].validate(valid => {
                    if (valid) {
                        this.loadAddBtn = true;
                        let tempData = this.sysArticlePass;
                        this.objAdd.sysFlag = tempData;
                        if (this.objAdd.content) {
                            let tempContent = this.objAdd.content;
                            tempContent = tempContent.replace(/\&/g, "%26");
                            this.objAdd.content = tempContent;
                        }
                        if(this.classIdValue) {
                            this.objAdd.classId=this.classIdValue;
                        }
                        add(this.objAdd).then(res => {
                            if (res.data.code == 200) {
                                this.loadAddBtn = false;
                                this.addDialogTableVisible = false;
                                this.$message({
                                    type: "success",
                                    message: "操作成功"
                                });
                                this.onLoad(this.page);
                                this.objAdd.content = "";
                                this.objAdd.classId = "";
                                this.objAdd.mark = "";
                                this.objAdd.title = "";
                                this.objAdd.keyword = "";
                                this.objAdd.content = "";
                                this.objAdd.author = "";
                                this.objAdd.source = "";
                                this.objAdd.url = "";
                                this.objAdd.display = "";
                                this.objAdd.sequence = "";
                                this.objAdd.sysFlag = "";
                            } else {
                                this.loadAddBtn = false;
                                this.$message({
                                    type: "error",
                                    message: res.data.message
                                });
                            }
                        }, error => {
                            this.loadAddBtn = false;
                        });
                    } else {
                        this.loadAddBtn = false;
                    }
                });
            },
            //编辑之后提交　
            commitCheck() {
                this.$refs['editArticle'].validate((valid) => {
                    if (valid) {
                        if (this.objEdit.content) {
                            let tempContent = this.objEdit.content;
                            tempContent = tempContent.replace(/\&/g, "%26");
                            this.objEdit.content = tempContent;
                            this.loadBtn = true;
                            let tempData = this.sysArticlePass;
                            this.objEdit.sysFlag = tempData;
                            update(this.objEdit).then(res => {
                                if (res.data.code == 200) {
                                    this.onLoad(this.page);
                                    this.loadBtn = false;
                                    this.dialogTableVisibleEdit = false;
                                    this.$message({
                                        type: "success",
                                        message: "操作成功"
                                    });
                                } else {
                                    this.loadBtn = false;
                                    this.$message({
                                        type: "error",
                                        message: res.data.message
                                    });
                                }
                            }, error => {
                                this.loadBtn = false;
                            });
                        } else {
                            this.loadBtn = false;
                            this.$message({
                                type: "error",
                                message: "请输入文章内容"
                            });
                        }
                    } else {
                        this.loadAddBtn = false;
                    }
                });
            },

            cancel() {
                this.dialogTableVisible = false;
                this.isCheck = false;
            },


            cancelAddEdit() {
                this.$refs.addArticle.resetForm();
                this.$refs.addArticle.clearValidate();
                this.addDialogTableVisible = false;
            },

            cancelEdit() {
                this.dialogTableVisibleEdit = false;
                this.objEdit = this.objEditTemp;
            },


            getContent(val) {
                this.objEdit.content = val;
            },

            getAddContent(val) {
                this.objAdd.content = val;
            },
            //点击新增分类按钮
            addPageInfoClass() {
                this.addClassDialogTableVisible = true;
            },
            //新增分类
            commitAddClassCheck(addArticleClass) {
                let tempData = this.sysArticlePass;
                this.objAddClass.sysFlag = tempData;
                this.$refs[addArticleClass].validate((valid) => {
                    if (valid) {
                        this.loadAddClassBtn = true;
                        addClass(this.objAddClass).then(res => {
                            if (res.data.code == 200) {
                                this.$message({
                                    type: "success",
                                    message: "操作成功!"
                                });
                                this.loadAddClassBtn = false;
                                this.addClassDialogTableVisible = false;
                                this.getTreeList();
                            } else {
                                this.$message.error(res.data.message);
                                this.loadAddClassBtn = false;
                            }
                        }, error => {
                        });
                    } else {
                        this.loadAddClassBtn = false;
                    }
                });

            },
            //新增分类取消
            cancelAddClass() {
                this.addClassDialogTableVisible = false;
                this.objAddClass.title = "";
                this.objAddClass.description = "";
                this.objAddClass.sequence = "";
            },

            loadClass(){
                let tempDicData = [];
                let sysFlag = this.whichPassData;
                getSelectList(sysFlag).then(res => {
                    tempDicData = res.data.data;
                    this.optionTree.column[1].dicData = tempDicData;
                })
            },

        }
    };
</script>

<style scoped>
    .list-tree-box {
        width: 100%;
        height: 450px;
        max-height: 450px;
        display: flex;
        flex-flow: column nowrap;
        justify-content: space-between;
    }

    .filter-tree {
        flex: 1;
        border: 1px solid #dcdfe6;
        border-radius: 6px;
        overflow-y: scroll;
    }

    .basic-box {
        width: 100%;
        height: 100% !important;
    }

    .basic-container .el-card {
        height: 100% !important;
    }

    .el-card.is-always-shadow,
    .el-card__body {
        width: 100%;
        height: 100% !important;
    }

    .el-container {
        height: 100% !important;
        padding-bottom: 5px;
    }

    .table-list {
        max-height: 560px;
        min-height: 560px;
    }

    .el-aside-tree-container {
        width: 210px !important;
        height: 100% !important;
        display: flex;
        flex-flow: column nowrap;
    }
</style>
